﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace F3.Maps.OsmParser
{
    public class GisUtility
    {

        public static double CalculateDistance(Point start, Point end)
        {
           double distance = CalculateDistance(double.Parse(start.Lat), double.Parse(start.Lon), double.Parse(end.Lat), double.Parse(end.Lon));
                     
           return distance;
        }
        
        public static double CalculateDistance(double pStartLat, double pStartLong, double pEndLat, double pEndLong)
        {

            double distance = /*for conversion in Metres*/
                               1000 *
                              /*radius of earth in km*/
                               6378.7 * Math.Acos(Math.Sin(pStartLat / 57.2958)
                                      * Math.Sin(pEndLat / 57.2958) 
                                      + Math.Cos(pStartLat / 57.2958)
                                      * Math.Cos(pEndLat / 57.2958)
                                      * Math.Cos((pEndLong / 57.2958) - (pStartLong / 57.2958)));
            return distance;
        }

        
    }
}
